//
//  MLSBottomView.swift
//  MLSMircoBlog
//
//  Created by 袁航 on 15/8/2.
//  Copyright © 2015年 yuanhang. All rights reserved.
//

import UIKit

class MLSBottomView: UIView {
    // 模型属性
    var status: MLSUserStatus? {
        didSet {
            if let repostcount = status?.reposts_count where repostcount != 0 {
                repostBtn.setTitle(" \(repostcount)" , forState: UIControlState.Normal)
            }
            if let commentcount = status?.comments_count where commentcount != 0 {
                commentsBtn.setTitle(" \(commentcount)", forState: UIControlState.Normal)
            }
            if let attitudecount = status?.attitudes_count where attitudecount != 0 {
                attitudesBtn.setTitle(" \(attitudecount)", forState: UIControlState.Normal)
            }
        }
    }
    init(){
        super.init(frame: CGRectZero)
        // 设置UI
        setupUI()
        
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    private func setupUI() {
        // 添加到视图中
        addSubview(repostBtn)
        addSubview(commentsBtn)
        addSubview(attitudesBtn)
        backgroundColor = UIColor.whiteColor()
        // 布局
        ff_HorizontalTile([repostBtn,commentsBtn,attitudesBtn], insets: UIEdgeInsets(top: 0, left: 1, bottom: 0, right: 1))

    }
    
    // MARK:- 懒加载控件
    private lazy var repostBtn: UIButton = UIButton(image: UIImage(named: "timeline_icon_retweet"), title:" 转发")
    private lazy var commentsBtn: UIButton = UIButton(image: UIImage(named: "timeline_icon_comment"), title: " 评论")
    private lazy var attitudesBtn: UIButton = UIButton(image: UIImage(named: "timeline_icon_unlike"), title: " 赞")
}
